package com.zhong.beautifulimageapp.fragments;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zhong.beautifulimageapp.R;
import com.zhong.beautifulimageapp.adapter.MyInfoListAdapter;
import com.zhong.beautifulimageapp.model.EventBusMessageAboutTopicID;
import com.zhong.beautifulimageapp.model.RecentRepliesEventBusMessage;
import com.zhong.beautifulimageapp.myView.NoScrollListView;
import com.zhong.beautifulimageapp.utils.BaseFragments;

import org.greenrobot.eventbus.Subscribe;


import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * A simple {@link Fragment} subclass.
 */
public class UserRecentRepliesFragment extends BaseFragments {


    @BindView(R.id.user_recent_replies_list)
    NoScrollListView mUserRecentRepliesList;

    public UserRecentRepliesFragment() {
        // Required empty public constructor
    }

    @Override
    public String getFragmentTitle() {
        return "最近回复";
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_user_recent_replies, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Subscribe
    public void getUserRecentReoliesData(RecentRepliesEventBusMessage repliesEventBusMessage) {
        MyInfoListAdapter adapter = new MyInfoListAdapter(getContext(), null, null, repliesEventBusMessage.getRepliesBeen());
        mUserRecentRepliesList.setAdapter(adapter);
    }

    /**
     * 用于用户详情界面中包含的三个fragment中展示的item点击头像后进入作者详情界面
     * @param authorName 作者名
     */
    @Subscribe
    public void getOtherLoginName(String authorName){
        goToMyInfo(authorName);
    }

    /**
     * 用于用户详情界面中包含的三个fragment中展示的item点击整体后进入话题详情界面
     * @param topicID 话题的ID
     */
    @Subscribe
    public void goToTopicDetailMessage(EventBusMessageAboutTopicID topicID){
        goToTopicDetail(topicID.getId());
    }
}
